<?php Block::put('breadcrumb') ?>
<ul>
    <li><a href="<?= Backend::url('summer/hjd/usertuijian') ?>">推荐关系图</a></li>
    <li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>

<div class="layout-row min-size">
    <div class="control-toolbar toolbar-padded">
        <div class="toolbar-item" data-calculate-width>
            <div class="relative loading-indicator-container size-input-text">
                <input
                        type="text"
                        id="search_text"
                        name="search"
                        value="<?= e($search_text) ?>"
                        class="form-control icon search growable"
                        placeholder="请输入完整的编号或手机号"
                        data-control="search"
                        autocomplete="off"
                        data-load-indicator
                        data-load-indicator-opaque
                />
            </div>
        </div>
    </div>
</div>

<div style="height: 350px;overflow: auto;" id="toolbarDiv">
    <ul id="tuijianTree" class="dtree" data-id="0"></ul>
</div>

<script type="text/javascript">
    layui.extend({
        dtree: "<?= url('plugins/summer/hub/assets/layui_ext/dtree/dtree') ?>", //定义该组件模块名
    }).use(['dtree','layer','jquery'], function(){
        var dtree = layui.dtree, layer = layui.layer, $ = layui.jquery;
        var data=<?= $dataTree ?>;
        // 初始化树
        var TuijianTree = dtree.render({
            elem: "#tuijianTree",
            data: data,// 使用data加载,指定该参数后树的第一次加载不会访问异步数据接口（url）
            dataStyle: "layuiStyle",  //使用layui风格的数据格式
            url: "<?= Backend::url('summer/hjd/usertuijian/getChildren') ?>", // 使用url加载（可与data加载同时存在）
            response:{message:"msg",statusCode:0},
            initLevel:1,//默认展开层级为1
            line:true,
            ficon: ["1","-1"],  // 显示非最后一级节点图标，隐藏最后一级节点图标
            icon: ["0","1"] // 使用
        });
        // 绑定节点点击
        dtree.on("node('tuijianTree')" ,function(obj){
        });
    });

    $("#search_text").keypress(function(e){
        if(e.keyCode == 13){
            searchInfo();
        }
    });
    function searchInfo(){
        var search_text = $("#search_text").val();
        var params = new URLSearchParams();
        params.append('search_text', search_text);
        var url="<?= Backend::url('summer/hjd/usertuijian') ?>"
        url=url+"?"+params.toString();
        location.href = url;
    }
</script>
